<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<%-- @author: Christian Baumhof --%>

<%-- Title --%>
<h1>
	<s:text name="title.editExams" />
</h1>

<%-- Student information --%>
<h2>
	<s:property value="student.lastName" />
	,
	<s:property value="student.firstName" />
</h2>

<%-- Maniple information --%>
<table class="formTable">
	<tr>
		<td><s:text name="lbl.maniple" /></td>
		<td><s:property value="student.maniple.name" /></td>
	</tr>
	<tr>
		<td><s:text name="lbl.subject" />:</td>
		<td><s:property value="subject.title" /> - <s:property
				value="subject.description" /></td>
	</tr>
</table>

<%-- Results --%>
<s:form theme="simple">
	<%-- Hidden data --%>
	<s:hidden name="id" />
	<s:hidden name="selectedSubjectId" />
	<s:hidden name="nrTries" />

	<%-- If no results are available --%>
	<s:if test="nrTries==0">
		<s:submit theme="simple" key="button.add" action="AddExam" />
		<s:submit theme="simple" key="button.cancel"
			action="ShowGradeOverview" />
		<s:if test="errorNoNewTryAllowed">
			<p class="errorMessage">
				<s:text name="error.noNewTryAllowed" />
			</p>
		</s:if>
	</s:if>

	<%-- If student has 1 result --%>
	<s:elseif test="nrTries==1">
		<%-- Hidden data --%>
		<s:hidden name="result.id" />
		<s:hidden name="result.examTry" />
		<s:hidden name="result.oralExam" />
		<s:hidden name="result.valid" />
		<s:hidden name="examination.id" />
		<s:hidden name="results[0].id" />

		<%-- First try --%>
		<h2>
			<s:text name="lbl.try1"></s:text>
		</h2>
		<table>
			<tr>
				<th><s:text name="lbl.grade" /></th>
				<th><s:text name="lbl.examDate" /></th>
				<th><s:text name="lbl.lecturer" /></th>
				<th><s:text name="lbl.typist" /></th>

			</tr>
			<tr>
				<td><s:select theme="simple" list="grades" name="result.grade"
						value="result.grade"></s:select></td>
				<td><s:textfield theme="simple" name="examination.date" />
				<td><s:textfield theme="simple" name="examination.lecturer" />
				<td><s:textfield theme="simple" name="result.typist" /></td>
			</tr>
		</table>
		<table class="formTable">
			<tr>
				<td><s:submit theme="simple" key="button.add" action="AddExam" /></td>
				<td><s:submit theme="simple" key="button.delete"
						action="DeleteExam" /></td>
			</tr>
		</table>
		<table class="formTable">
			<tr>
				<td><s:submit theme="simple" key="button.save"
						action="SaveExam" /></td>
				<td><s:submit theme="simple" key="button.cancel"
						action="ShowGradeOverview" /></td>
			</tr>
		</table>
		<s:if test="errorNoNewTryAllowed">
			<p class="errorMessage">
				<s:text name="error.noNewTryAllowed" />
			</p>
		</s:if>
	</s:elseif>

	<%-- If student has 2 results --%>
	<s:elseif test="nrTries==2">
		<%-- Hidden data --%>
		<s:hidden name="result.id" />
		<s:hidden name="result.examTry" />
		<s:hidden name="result.oralExam" />
		<s:hidden name="result.valid" />
		<s:hidden name="examination.id" />

		<%-- First try --%>
		<h2>
			<s:text name="lbl.try1"></s:text>
		</h2>
		<table>
			<tr>
				<th><s:text name="lbl.grade" /></th>
				<th><s:text name="lbl.examDate" /></th>
				<th><s:text name="lbl.lecturer" /></th>
				<th><s:text name="lbl.typist" /></th>

			</tr>
			<tr>
				<td><s:select disabled="true" theme="simple" list="grades"
						name="results[0].grade" value="results[0].grade"></s:select></td>
				<td><s:textfield disabled="true" theme="simple"
						name="results[0].examination.date" />
				<td><s:textfield disabled="true" theme="simple"
						name="results[0].examination.lecturer" />
				<td><s:textfield disabled="true" theme="simple"
						name="results[0].typist" /></td>
			</tr>
		</table>

		<%-- Second try --%>
		<h2>
			<s:text name="lbl.try2"></s:text>
		</h2>
		<table>
			<tr>
				<th><s:text name="lbl.grade" /></th>
				<th><s:text name="lbl.examDate" /></th>
				<th><s:text name="lbl.lecturer" /></th>
				<th><s:text name="lbl.typist" /></th>

			</tr>
			<tr>
				<td><s:select theme="simple" list="grades" name="result.grade"
						value="result.grade"></s:select></td>
				<td><s:textfield theme="simple" name="examination.date" />
				<td><s:textfield theme="simple" name="examination.lecturer" />
				<td><s:textfield theme="simple" name="result.typist" /></td>
			</tr>
		</table>
		<table class="formTable">
			<tr>
				<td><s:submit theme="simple" key="button.add" action="AddExam" /></td>
				<td><s:submit theme="simple" key="button.delete"
						action="DeleteExam" /></td>
			</tr>
		</table>
		<table class="formTable">
			<tr>
				<td><s:submit theme="simple" key="button.save"
						action="SaveExam" /></td>
				<td><s:submit theme="simple" key="button.cancel"
						action="ShowGradeOverview" /></td>
			</tr>
		</table>
		<s:if test="errorNoNewTryAllowed">
			<p class="errorMessage">
				<s:text name="error.noNewTryAllowed" />
			</p>
		</s:if>
	</s:elseif>

	<%-- If student has 3 results --%>
	<s:elseif test="nrTries==3">
		<%-- Hidden data --%>
		<s:hidden name="result.id" />
		<s:hidden name="result.examTry" />
		<s:hidden name="result.oralExam" />
		<s:hidden name="result.valid" />
		<s:hidden name="examination.id" />

		<%-- First try --%>
		<h2>
			<s:text name="lbl.try1"></s:text>
		</h2>
		<table>
			<tr>
				<th><s:text name="lbl.grade" /></th>
				<th><s:text name="lbl.examDate" /></th>
				<th><s:text name="lbl.lecturer" /></th>
				<th><s:text name="lbl.typist" /></th>

			</tr>
			<tr>
				<td><s:select disabled="true" theme="simple" list="grades"
						name="results[0].grade" value="results[0].grade"></s:select></td>
				<td><s:textfield disabled="true" theme="simple"
						name="results[0].examination.date" />
				<td><s:textfield disabled="true" theme="simple"
						name="results[0].examination.lecturer" />
				<td><s:textfield disabled="true" theme="simple"
						name="results[0].typist" /></td>
			</tr>
		</table>

		<%-- Second try --%>
		<h2>
			<s:text name="lbl.try2"></s:text>
		</h2>
		<table>
			<tr>
				<th><s:text name="lbl.grade" /></th>
				<th><s:text name="lbl.examDate" /></th>
				<th><s:text name="lbl.lecturer" /></th>
				<th><s:text name="lbl.typist" /></th>

			</tr>
			<tr>
				<td><s:select disabled="true" theme="simple" list="grades"
						name="results[2].grade" value="results[2].grade"></s:select></td>
				<td><s:textfield disabled="true" theme="simple"
						name="results[2].examination.date" />
				<td><s:textfield disabled="true" theme="simple"
						name="results[2].examination.lecturer" />
				<td><s:textfield disabled="true" theme="simple"
						name="results[2].typist" /></td>
			</tr>
		</table>

		<%-- Third try --%>
		<h2>
			<s:text name="lbl.try3"></s:text>
		</h2>
		<table>
			<tr>
				<th><s:text name="lbl.grade" /></th>
				<th><s:text name="lbl.examDate" /></th>
				<th><s:text name="lbl.lecturer" /></th>
				<th><s:text name="lbl.typist" /></th>

			</tr>
			<tr>
				<td><s:select theme="simple" list="grades" name="result.grade"
						value="result.grade"></s:select></td>
				<td><s:textfield theme="simple" name="examination.date" />
				<td><s:textfield theme="simple" name="examination.lecturer" />
				<td><s:textfield theme="simple" name="result.typist" /></td>
			</tr>
		</table>
		<table class="formTable">
			<tr>
				<td><s:submit theme="simple" key="button.delete"
						action="DeleteExam" /></td>
			</tr>
		</table>
		<table class="formTable">
			<tr>
				<td><s:submit theme="simple" key="button.save"
						action="SaveExam" /></td>
				<td><s:submit theme="simple" key="button.cancel"
						action="ShowGradeOverview" /></td>
			</tr>
		</table>

	</s:elseif>
</s:form>
